package com.zsrt.java.day20170109.lh.daily.demo07;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import org.junit.Test;

/**
 * 
 * 			胡斌	24  18676758812  
			刘浩	24  15766472216 
			陈皋	23	18617067326  

 * 
 * @author My
 *
 */
public class MapTest {
	
	@Test
	public void mapTest() throws Exception {
		
		Map<String,Student> map=new HashMap<String,Student>();
		
		Student hb=new Student();
		hb.setName("胡斌");
		hb.setAge(24);
		hb.setPhone("18676758812");
		map.put("胡斌", hb);
		
		Student lh=new Student();
		lh.setName("刘浩");
		lh.setAge(24);
		lh.setPhone("15766472216");
		map.put("刘浩", lh);
		
		Student cg=new Student();
		cg.setName("陈皋");
		cg.setAge(24);
		cg.setPhone("18676758812");
		map.put("陈皋", cg);
		
		//得到一个 key的 集合
		Set<String> key = map.keySet();
		
		//得到
		Iterator<String> it = key.iterator();
		
		while(it.hasNext()){
			
			//得到每个键的值
			String keyname = it.next();
			
			//用键得到值
			System.out.println(keyname +map.get(keyname));
		}
		
		
	}

}
